﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Client.Controllers
{
    public class newController : Controller
    {
        // GET: /new/
        LF.LYLSoapClient service = new LF.LYLSoapClient();
        public ActionResult DAadd()//档案注册
        {
            ViewBag.EmployID = new SelectList(service.YGshow().ToList(), "EmployID", "EmployName");
            return View();
        }
        public ActionResult DAaddro(LF.DA da)//档案注册方法调用
        {
            int i = service.DAadd(da);
            if (i > 0)
            {
                return Content("<script>alert('注册成功！');location.href='/new/Dashow/'</script>");
            }
            else
            {
                return Content("<script>alert('注册失败！');location.href='/new/Daadd/'</script>");
            }
        }

        public ActionResult YGshow()//员工基本信息
        {
            var user = service.YGshow().ToList();
            return View(user);
        }

        public ActionResult DAshow()//档案表显示
        {
            var user = service.DAshow().ToList();
            return View(user);
        }
        public int DAdel(LF.DA da)//档案删除
        {
            return service.DAdel(da);
        }
        public ActionResult DAEXist(LF.DA da, int did)//档案编辑查询
        {      
            var user = service.DAEXist(da,did);
            ViewBag.EmployID = new SelectList(service.YGshow().ToList(), "EmployID", "EmployName",user.EmployID);
            return View(user);
        }
        public ActionResult DAupdate(int did, LF.DA da)//档案修改
        {
            int i = service.DAupdate(did,da);
            if (i > 0)
            {
                return Content("<script>alert('修改成功！');location.href='/new/Dashow/'</script>");
            }
            else
            {
                return Content("<script>alert('修改失败！');location.href='/new/Daadd/'</script>");
            }
        }
        public ActionResult HTadd(LF.hetong ge)//合同添加
        {
            ViewBag.EmployID = new SelectList(service.YGshow().ToList(), "EmployID", "EmployName");
            ViewBag.PositionID = new SelectList(service.ZWshow().ToList(), "PositionID", "PositionName");
            return View();
        }
        public ActionResult HTaddor(LF.hetong ht)//合同添加方法调用
        {
            int i = service.HTadd(ht);
            if (i > 0)
            {
                return Content("<script>alert('注册成功！');location.href='/new/HTshow'</script>");
            }
            else
            {
                return Content("<script>alert('注册失败！');location.href='/new/HTshow'</script>");
            }
        }
        public ActionResult HTshow()//合同表显示
        {
            var user = service.HTshow().ToList();
            return View(user);
        }
        public ActionResult HTdel(int hid)//合同删除
        {
            int i = service.HTdel(hid);
            if (i > 0)
            {
                return Content("<script>alert('删除成功！');location.href='/new/HTshow'</script>");
            }
            else
            {
                return Content("<script>alert('删除失败！');location.href='/new/HTshow'</script>");
            }
        }
        public ActionResult HTEXist(int hid)//合同表反填
        {
            var user = service.HTEXist(hid);
            ViewBag.EmployID = new SelectList(service.YGshow().ToList(), "EmployID", "EmployName",user.EmployID);
            ViewBag.PositionID = new SelectList(service.ZWshow().ToList(), "PositionID", "PositionName",user.PositionID);
            return View(user);
        }
        public ActionResult HTupdate(int hid,LF.hetong he)//合同修改
        {
            int i = service.HTupdate(hid,he);
            if (i > 0)
            {
                return Content("<script>alert('修改成功！');location.href='/new/HTshow'</script>");
            }
            else
            {
                return Content("<script>alert('修改失败！');location.href='/new/HTEXist'</script>");
            }
        }

        public ActionResult reward_tabadd()//奖罚表添加
        {
            ViewBag.EmployID = new SelectList(service.YGshow().ToList(),"EmployID","EmployName");
            ViewBag.pid = new SelectList(service.price_tabshow().ToList(),"pid","pname");
            return View();
        }
        public ActionResult reward_tabaddor(LF.reward_tab re)//奖罚表添加方法调用
        {
            int i = service.reward_tabadd(re);
            if (i > 0)
            {
                return Content("<script>alert('注册成功！');location.href='/new/reward_tabshow'</script>");
            }
            else
            {
                return Content("<script>alert('注册失败！');location.href='/new/reward_tabadd'</script>");
            }
        }
        public ActionResult reward_tabshow()//奖罚表显示
        {
            var user = service.reward_tabshow().ToList();
            return View(user);
        }      
        public ActionResult reward_tabExist(int rid)//奖罚表反填
        {
            var user = service.reward_tabExist(rid);
            ViewBag.EmployID = new SelectList(service.YGshow().ToList(), "EmployID", "EmployName",user.EmployID);
            ViewBag.pid = new SelectList(service.price_tabshow().ToList(), "pid", "pname",user.pid);
            return View(user);
        }
        public ActionResult reward_tabdel(int rid)//奖罚表删除
        {
            int i = service.reward_tabdel(rid);
            if (i > 0)
            {
                return Content("<script>alert('删除成功！');location.href='/new/reward_tabshow'</script>");
            }
            else
            {
                return Content("<script>alert('删除失败！');location.href='/new/reward_tabshow'</script>");
            }
        }
        public ActionResult reward_tabupdate(int rid,LF.reward_tab re)//奖罚表修改
        {
            int i = service.reward_tabupdate(rid, re);
            if (i > 0)
            {
                return Content("<script>alert('修改成功！');location.href='/new/reward_tabshow'</script>");
            }
            else
            {
                return Content("<script>alert('修改失败！');location.href='/new/reward_tabshow'</script>");
            }
        }

    }
}
